<div class="box-tools" style="top:10px;">
  <form class="form-inline" id="project—form" action="{:url('money/cashpaymentindex')}" method="GET" pjax-search="">

    <div class="form-group">
      <label for="payment_status">兑付状态</label>
      <select class="form-control" name="cash_payment_status" id="cash_payment_status" style="border-radius:3px;">
        <option value="-1">全部</option>
        <option value="2" {if condition="input('get.cash_payment_status') eq 2" }selected="selected" {/if} >已失败</option>
        <option value="0" {if condition="input('get.cash_payment_status') === '0'" }selected="selected" {/if} >待处理</option>
        <option value="1" {if condition="input('get.cash_payment_status') eq 1" }selected="selected" {/if} >已成功</option>
      </select>
    </div>
    <div class="form-group">
      <label for="search">关键字</label>
      <input type="text" name="search" id="search" class="form-control" value="{:input('get.search')}"
             placeholder="会员名称/手机号"/>
    </div>
    <div class="form-group">
      <button type="submit" class="btn btn-primary sreachs">搜索</button>
      <button type="button" id="dwonload" class="btn btn-primary sreachs">下载</button>
      <button type="button" class="btn btn-primary" onclick="resetForm()">重置</button>
    </div>
  </form>
</div>
<script>
    $(function () {
        $('#dwonload').click(function () {
            var url = "{:url('money/cashpaymentindex')}";
            var cash_payment_status = $("select[name='cash_payment_status']").val();
            var search = $("input[name='search']").val();
            location.href = url + "?cash_payment_status=" + cash_payment_status + "&search=" + search + "&down=1";
        })
        let start_date = $('#start_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn'),
        }).on('dp.change', function (e) {
           let initEndDate = $('#end_date').val()
            end_date.data('DateTimePicker').minDate(e.date);
            if(initEndDate === ''){
              $('#end_date').val('')
            }

        });
        let end_date = $('#end_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        }).on('dp.change', function (e) {
            start_date.data('DateTimePicker').maxDate(e.date);
        });
    })

    function resetForm() {
        $('select[name="project_id"]').val('')
        $('select[name="status"]').val('-1')
        $('select[name="cash_payment_status"]').val('-1')
        $('input[name="start_date"]').val('')
        $('input[name="end_date"]').val('')
        $('input[name="search"]').val('')
        $('#project—form').submit()
    }
</script>